package com.zmkj.cn.sys.controller;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.zmkj.cn.sys.service.ISysManagerService;
import com.zmkj.cn.sys.vo.input.SysRegistInputVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;

/**
 * 用户接口
 * @author 伍绍宇
 * @date 2021/04/23
 */
@Api(tags ="用户表接口")
@RestController
@RequestMapping("/user")
@Slf4j
public class SysManagerController {

	
    @Resource
    private ISysManagerService sysManagerService;


    /**
     * 注册用户
     *
     */
    @RequestMapping("/registerUser")
    @ApiOperation(value = "注册用户", httpMethod = "POST", notes = "注册用户")
    @ApiResponses({ @ApiResponse(code = 200, message = "注册用户成功")})
    public Object registUser(HttpServletRequest request, @Valid @ModelAttribute SysRegistInputVo sysRegistInputVo){
        return sysManagerService.registUser(sysRegistInputVo, request);
    }

    /**
     * 删除用户
     *
     */
    @RequestMapping("/removeUser")
    @ApiOperation(value = "删除用户", httpMethod = "POST", notes = "删除用户")
    @ApiResponses({ @ApiResponse(code = 200, message = "删除用户成功")})
    public Object removeUser( HttpServletRequest request, @Valid  @ModelAttribute SysRegistInputVo sysRegistInputVo){
        return sysManagerService.removeUser(sysRegistInputVo, request);
    }
    
    
    /**
     * 用户同步
     * **/
    
    @PostMapping("/readUser")
    @ApiOperation(value = "redis用户同步", httpMethod = "POST", notes = "redis用户同步")
    @ApiResponses({ @ApiResponse(code = 200, message = "redis用户同步")})
    public Object readUser( HttpServletRequest request, @Valid  @ModelAttribute SysRegistInputVo sysRegistInputVo){
    	log.info("*********{}********",JSON.toJSONString(sysRegistInputVo));
    	return sysManagerService.readUser(sysRegistInputVo, request);
		 
    }
    	

}
